//
//  CommonHeader.swift
//  shop
//
//  Created by chen on 2025/5/17.
//

import SwiftUI

struct CommonHeader: View {
    
    @Environment(\.dismiss) private var dismiss
    @EnvironmentObject private var router: Router
    
    var title: String
    
    var body: some View {
        ZStack{
            Text(title)
                .font(.system(size: 17))
                .bold()
                .padding(.vertical, 10)
            
            HStack(spacing: 0){
                Button {
                    dismiss()
                } label: {
                    Image(systemName: "chevron.left")
                        .foregroundColor(.black)
                }

                Spacer()
                
                HStack(spacing: 5){
                    Button(action: {
                        router.to(.searchView)
                    }) {
                        Image(systemName: "magnifyingglass")
                            .foregroundColor(.black)
                    }
                }
                .padding(.trailing, 5)
            }
            .padding(.horizontal, 10)
            .padding(.vertical, 10)
        }
        .background(.white)
    }
}
